# Replication package for: Trade-Policy Dynamics: Evidence from 60 Years of U.S.-China Trade
Alessandria,  Khan, Khederlarian, Ruhl, and Steinberg

## 1 Data

All data used in this project are publicly available, except for the data listed in the "Confidential data" section below.

The data used are included in this replication package to guard against revisions to data making replication difficult. Links to the data sources and their sources are in `Docs/`.

### 1.1 Confidential data
The firm-level moments from the Chinese data reported in table 1 are created from a panel of data that is not publicly available.  

The data for Chinese firms comes from an annual survey of manufacturing enterprises collected by the Chinese National Bureau of Statistics (NBS China (1998-2007)). This data is proprietary and cannot be posted, but it is accessible through the CUHK-Tsinghua Research Center on the Chinese Economy (https://research-center.econ.cuhk.edu.hk/en-gb/). Please write to CT-CCE@cuhk.edu.hk to use the data to replicate our results.


## 2 Replication

There are three main parts of the replication: 

1. Data preparation and the regression models 
2. The structural model (which uses output of the regression models) 
3. Creation of  figures, tables, and numbers in the text (which uses output of the regression models and the structural models)

The three parts are described below and need to be replicated in the order presented. 

### 2.1 Data preparation and reduced-form modeling
The nature of STATA requires reading and writing to the hard disk often. Turning off syncing applications (e.g., Dropbox) may be necessary.

#### Requirements
* STATA and packages
	* egenmore
	* unique
	* estout
	* reghdfe
	* ftools
	* ivreghdfe
	* ivreg2
	* ranktest

Execute "00 run all files.do", or run, in this order:

* 01 preliminaries.do (<1 min)
* 02 process raw data (~12 min)
* 03 process raw data (~1.5 min)
* 10 trade analysis (~11 min)
* 20 employment analysis (~1.5 min)
* 30 create calibration inputs ( min)

All files are in "10 Code data and reduced form models"

### 2.2 Structural model

#### Requirements
* At least 20 processing cores, but 60+ for reasonable running times
* Python 3 and packages
	* numpy
	* scipy
	* matplotlib
	* statsmodels
	* seaborn
* gcc C compiler
* OpenMP library
* GSL library

See the readme file in `11 Code structural model` for details and instruction. 

### 2.3 Final output creation

### Requirements
* python3 and packages
	* jupyter notebook 
	* pandas
	* numpy
	* matplotlib
	* statsmodels
	* math

Run, in order  

* 00 figures.ipynb
* 10 tables.ipynb
 
Both files are in `12 Code final outputs`.

# 3 Tables and figures
When created, tables and figures are saved in `30 Final output files`.

| Exhibit | Created in | File name|
|---------|------------|----------|
|Table 1| 12 Code final outputs/10 tables.ipynb|table1.tex|
|Table 2| 12 Code final outputs/10 tables.ipynb|table2.tex|
|Table 3| Mostly compiled from external sources|in main.tex|
|Figure 1|12 Code final outputs/00 figures.ipynb|fig1.pdf|
|Figure 2|12 Code final outputs/00 figures.ipynb|fig2.pdf|
|Figure 3|12 Code final outputs/00 figures.ipynb|fig3.pdf|
|Figure 4|12 Code final outputs/00 figures.ipynb|fig4.pdf|
|Figure 5|12 Code final outputs/00 figures.ipynb|fig5.pdf|
|Figure 6|12 Code final outputs/00 figures.ipynb|fig6.pdf|
|Figure 7|12 Code final outputs/00 figures.ipynb|fig7.pdf|


